package com.ljy.my_study.java.文件io;

import org.apache.commons.io.output.ByteArrayOutputStream;

import java.io.*;

public class TestMain {

    public static void main(String[] args) throws IOException {
        String filePath="D:\\project\\git\\my_study\\my-study\\pom.xml";
        File file=new File(filePath);
        ByteArrayOutputStream os=new ByteArrayOutputStream();
        os.write(new FileInputStream(file));
//        File newFile=new File("D:\\project\\git\\my_study\\my-study\\pom.xml.bak");
//        FileOutputStream fileOutputStream=new FileOutputStream(newFile);
//        os.writeTo(fileOutputStream);
//        fileOutputStream.close();

        InputStream inputStream=os.toInputStream();
        BufferedReader br=new BufferedReader(new InputStreamReader(inputStream));
        String line=null;
        while((line=br.readLine())!=null){
            System.out.println(line);
        }
        br.close();
        inputStream.close();

        os.close();
    }
}
